package logic

import (
	"B/shenzhou_srv/model/mysql"
	"context"

	"B/shenzhou_srv/internal/svc"
	"B/shenzhou_srv/shenzhou"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserListLogic {
	return &UserListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserListLogic) UserList(in *shenzhou.UserListRequest) (*shenzhou.UserListResponse, error) {
	// todo: add your logic here and delete this line
	var u mysql.User
	list := u.List(in.Status)

	var user []*shenzhou.UserList
	for _, u2 := range list {
		user = append(user, &shenzhou.UserList{
			UserId:   int64(u2.ID),
			Username: u2.Username,
			Password: u2.Password,
			Status:   u2.Status,
		})
	}
	return &shenzhou.UserListResponse{List: user}, nil
}
